<?php echo $header; ?>
<div id="content">
  <div class="breadcrumb">
    <?php foreach ($breadcrumbs as $breadcrumb) { ?>
    <?php echo $breadcrumb['separator']; ?><a href="<?php echo $breadcrumb['href']; ?>"><?php echo $breadcrumb['text']; ?></a>
    <?php } ?>
  </div>
  <?php if ($error_warning) { ?>
  <div class="warning"><?php echo $error_warning; ?></div>
  <?php } ?>
  <div class="box">
    <div class="heading">
      <h1><img src="view/image/module.png" alt="" /> <?php echo $heading_title; ?></h1>
      <div class="buttons"><a onclick="$('#form').submit();" class="button"><?php echo $button_save; ?></a><a href="<?php echo $cancel; ?>" class="button"><?php echo $button_cancel; ?></a></div>
    </div>
    <div class="content">
      <form action="<?php echo $action; ?>" method="post" enctype="multipart/form-data" id="form">
        <table id="module" class="list">
          <thead>
            <tr>
              <td class="left"><?php echo $entry_banner; ?></td>
              <td class="left"><?php echo $entry_dimension; ?></td>
               <td class="left"><?php echo $entry_dimension_thumb; ?></td>
              <td class="left"><?php echo $entry_type; ?></td>
             
              <td class="left"><?php echo $entry_layout; ?></td>
              <td class="left"><?php echo $entry_position; ?></td>
              <td class="left"><?php echo $entry_status; ?></td>
              <td class="right"><?php echo $entry_sort_order; ?></td>
              <td></td>
            </tr>
          </thead>
          <?php $module_row = 0; ?>
          <?php foreach ($modules as $module) { 
          	$span3=$span4=$span6=$span9=$span12="";
			if($module['span_width']=="span3"){
				$span3="selected";
			}elseif($module['span_width']=="span4"){
				$span4="selected";
			}elseif($module['span_width']=="span6"){
				$span6="selected";
			}elseif($module['span_width']=="span9"){
				$span9="selected";
			}elseif($module['span_width']=="span12"){
				$span12="selected";
			}
          	
          	?>
          <tbody id="module-row<?php echo $module_row; ?>">
            <tr>
              <td class="left"><select name="slideshow_module[<?php echo $module_row; ?>][banner_id]">
                  <?php foreach ($banners as $banner) { ?>
                  <?php if ($banner['banner_id'] == $module['banner_id']) { ?>
                  <option value="<?php echo $banner['banner_id']; ?>" selected="selected"><?php echo $banner['name']; ?></option>
                  <?php } else { ?>
                  <option value="<?php echo $banner['banner_id']; ?>"><?php echo $banner['name']; ?></option>
                  <?php } ?>
                  <?php } ?>
                </select></td>
              <td class="left"><input type="text" name="slideshow_module[<?php echo $module_row; ?>][width]" value="<?php echo $module['width']; ?>" size="3" />
                <input type="text" name="slideshow_module[<?php echo $module_row; ?>][height]" value="<?php echo $module['height']; ?>" size="3"/>
               <select name="slideshow_module[<?php echo $module_row; ?>][span_width]">
               		<option value="span3" <?php echo $span3; ?> >span3</option>
               		<option value="span4" <?php echo $span4; ?> >span4</option>
               		<option value="span6" <?php echo $span6; ?> >span6</option>
               		<option value="span9" <?php echo $span9; ?> >span9</option>
               		<option value="span12" <?php echo $span12; ?> >span12</option>
               </select>
                <?php if (isset($error_dimension[$module_row])) { ?>
                <span class="error"><?php echo $error_dimension[$module_row]; ?></span>
                <?php } ?></td>
                
              <td class="left"><input type="text" name="slideshow_module[<?php echo $module_row; ?>][width_thumb]" value="<?php echo (isset($module['width_thumb']))?$module['width_thumb']:"173"; ?>" size="3" />
                <input type="text" name="slideshow_module[<?php echo $module_row; ?>][height_thumb]" value="<?php echo (isset($module['height_thumb']))?$module['height_thumb']:"172"; ?>" size="3"/>
				</td>
				
              <td class="left">
              	<?php 
              	$selType1=$selType2=$selType3=$selType4=$selType5="";
				$selType6=$selType7=$selType7=$selType8=$selType9=$selType10="";
				
					if(isset($module['type']) && $module['type']=="fullscreen"){
						$selType1="selected";
					}elseif(isset($module['type']) && $module['type']=="partialview"){
						$selType2="selected";
					}elseif(isset($module['type']) && $module['type']=="gallery"){
						$selType3="selected";
					}elseif(isset($module['type']) && $module['type']=="showcase"){
						$selType4="selected";
					}elseif(isset($module['type']) && $module['type']=="3d"){
						$selType5="selected";
					}elseif(isset($module['type']) && $module['type']=="tabs"){
						$selType6="selected";
					}elseif(isset($module['type']) && $module['type']=="showcase_v"){
						$selType7="selected";
					}elseif(isset($module['type']) && $module['type']=="vertical"){
						$selType8="selected";
					}elseif(isset($module['type']) && $module['type']=="videogallery"){
						$selType9="selected";
					}elseif(isset($module['type']) && $module['type']=="videogallery_v"){
						$selType10="selected";
					}else{
						$selType1="selected";
					}
              	?>
              		<select name="slideshow_module[<?php echo $module_row; ?>][type]">
						<option value="fullscreen" <?php echo $selType1; ?> >fullscreen</option>
						<option value="partialview" <?php echo $selType2; ?> >partialview</option>
						<option value="gallery" <?php echo $selType3; ?> >gallery</option>
						<option value="showcase" <?php echo $selType4; ?> >showcase</option>
						<option value="showcase_v" <?php echo $selType7; ?> >showcase vertical</option>
						<option value="3d" <?php echo $selType5; ?> >3d</option>
						<option value="tabs" <?php echo $selType6; ?> >tabs</option>
						<option value="vertical" <?php echo $selType8; ?> >vertical</option>
						<!--<option value="videogallery" <?php echo $selType9; ?> >videogallery</option>-->
						<!--<option value="videogallery_v" <?php echo $selType10; ?> >videogallery vertical</option>-->
                </select></td>
                
              <td class="left"><select name="slideshow_module[<?php echo $module_row; ?>][layout_id]">
                  <?php foreach ($layouts as $layout) { ?>
                  <?php if ($layout['layout_id'] == $module['layout_id']) { ?>
                  <option value="<?php echo $layout['layout_id']; ?>" selected="selected"><?php echo $layout['name']; ?></option>
                  <?php } else { ?>
                  <option value="<?php echo $layout['layout_id']; ?>"><?php echo $layout['name']; ?></option>
                  <?php } ?>
                  <?php } ?>
                </select></td>
              <td class="left"><select name="slideshow_module[<?php echo $module_row; ?>][position]">
                  <?php if ($module['position'] == 'content_top') { ?>
                  <option value="content_top" selected="selected"><?php echo $text_content_top; ?></option>
                  <?php } else { ?>
                  <option value="content_top"><?php echo $text_content_top; ?></option>
                  <?php } ?>
                  <?php if ($module['position'] == 'content_bottom') { ?>
                  <option value="content_bottom" selected="selected"><?php echo $text_content_bottom; ?></option>
                  <?php } else { ?>
                  <option value="content_bottom"><?php echo $text_content_bottom; ?></option>
                  <?php } ?>
                  <?php if ($module['position'] == 'column_left') { ?>
                  <option value="column_left" selected="selected"><?php echo $text_column_left; ?></option>
                  <?php } else { ?>
                  <option value="column_left"><?php echo $text_column_left; ?></option>
                  <?php } ?>
                  <?php if ($module['position'] == 'column_right') { ?>
                  <option value="column_right" selected="selected"><?php echo $text_column_right; ?></option>
                  <?php } else { ?>
                  <option value="column_right"><?php echo $text_column_right; ?></option>
                  <?php } ?>
                </select></td>
              <td class="left"><select name="slideshow_module[<?php echo $module_row; ?>][status]">
                  <?php if ($module['status']) { ?>
                  <option value="1" selected="selected"><?php echo $text_enabled; ?></option>
                  <option value="0"><?php echo $text_disabled; ?></option>
                  <?php } else { ?>
                  <option value="1"><?php echo $text_enabled; ?></option>
                  <option value="0" selected="selected"><?php echo $text_disabled; ?></option>
                  <?php } ?>
                </select></td>
              <td class="right"><input type="text" name="slideshow_module[<?php echo $module_row; ?>][sort_order]" value="<?php echo $module['sort_order']; ?>" size="3" /></td>
              <td class="left"><a onclick="$('#module-row<?php echo $module_row; ?>').remove();" class="button"><?php echo $button_remove; ?></a></td>
            </tr>
          </tbody>
          <?php $module_row++; ?>
          <?php } ?>
          <tfoot>
            <tr>
              <td colspan="6"></td>
              <td class="left"><a onclick="addModule();" class="button"><?php echo $button_add_module; ?></a></td>
            </tr>
          </tfoot>
        </table>
      </form>
    </div>
  </div>
</div>
<script type="text/javascript"><!--
var module_row = <?php echo $module_row; ?>;

function addModule() {	
	html  = '<tbody id="module-row' + module_row + '">';
	html += '  <tr>';
	html += '    <td class="left"><select name="slideshow_module[' + module_row + '][banner_id]">';
	<?php foreach ($banners as $banner) { ?>
	html += '      <option value="<?php echo $banner['banner_id']; ?>"><?php echo addslashes($banner['name']); ?></option>';
	<?php } ?>
	html += '    </select></td>';
	html += '    <td class="left"><input type="text" name="slideshow_module[' + module_row + '][width]" value="" size="3" /> <input type="text" name="slideshow_module[' + module_row + '][height]" value="" size="3" />';
		html += ' <select name="slideshow_module[' + module_row + '][span_width]">';
	   		html += ' <option value="span3">span3</option>';
	   		html += ' <option value="span4">span4</option>';
	    	html += ' <option value="span6">span6</option>';
	     	html += ' <option value="span9">span9</option>';
	      	html += ' <option value="span12">span12</option>';
		html += ' </select>';
	 html += ' </td>';

	html += '    <td class="left"><input type="text" name="slideshow_module[' + module_row + '][width_thumb]" value="" size="3" /> <input type="text" name="slideshow_module[' + module_row + '][height_thumb]" value="" size="3" />';
	 html += ' </td>';
	 
	html +='<td class="left"><select name="slideshow_module[' + module_row + '][type]">';
		html += '<option value="fullscreen"  >fullscreen</option>';
		html += '<option value="partialview" >partialview</option>';
		html += '<option value="gallery" >gallery</option>';
		html += '<option value="showcase" >showcase</option>';
		html += '<option value="3d" >3d</option>';
		html += '<option value="tabs">tabs</option>';
		html += '<option value="showcase_v" >showcase-vertical</option>';
		html += '<option value="vertical" >vertical</option>';
		html += '<option value="videogallery" >videogallery</option>';
		html += '<option value="videogallery_v" >videogallery-vertical</option>';
	html +='</select></td>';

	html += '<td class="left"><select name="slideshow_module[' + module_row + '][layout_id]">';
	<?php foreach ($layouts as $layout) { ?>
	html += '      <option value="<?php echo $layout['layout_id']; ?>"><?php echo addslashes($layout['name']); ?></option>';
	<?php } ?>
	html += '    </select></td>';
	html += '    <td class="left"><select name="slideshow_module[' + module_row + '][position]">';
	html += '      <option value="content_top"><?php echo $text_content_top; ?></option>';
	html += '      <option value="content_bottom"><?php echo $text_content_bottom; ?></option>';
	html += '      <option value="column_left"><?php echo $text_column_left; ?></option>';
	html += '      <option value="column_right"><?php echo $text_column_right; ?></option>';
	html += '    </select></td>';
	html += '    <td class="left"><select name="slideshow_module[' + module_row + '][status]">';
    html += '      <option value="1" selected="selected"><?php echo $text_enabled; ?></option>';
    html += '      <option value="0"><?php echo $text_disabled; ?></option>';
    html += '    </select></td>';
	html += '    <td class="right"><input type="text" name="slideshow_module[' + module_row + '][sort_order]" value="" size="3" /></td>';
	html += '    <td class="left"><a onclick="$(\'#module-row' + module_row + '\').remove();" class="button"><?php echo $button_remove; ?></a></td>';
	html += '  </tr>';
	html += '</tbody>';
	
	$('#module tfoot').before(html);
	
	module_row++;
}
//--></script> 
<?php echo $footer; ?>